//
//  LYFNearbyViewController.m
//  段子手
//
//  Created by dllo on 16/3/18.
//  Copyright © 2016年 JokesTeam. All rights reserved.
//

#import "LYFNearbyViewController.h"

@interface LYFNearbyViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, retain) UITableView *tableView;/**< 附近tableview */
@property (nonatomic, retain) UIBarButtonItem *backButton;/**< 左上角返回按钮 */

@end

@implementation LYFNearbyViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}

- (void)dealloc {
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationItem.title = @"附近段子手";
    
    
    self.backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"fanhui.png"] style:0 target:self action:@selector(backButtonAction:)];
    self.navigationItem.leftBarButtonItem = _backButton;
    
    [self dataHandle];
    [self createTableView];
}

/** 创建附近tableview */
- (void)createTableView {
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HETGHT) style:UITableViewStylePlain];
    [self.view addSubview:_tableView];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [_tableView registerClass:[LYFNearbyTableViewCell class] forCellReuseIdentifier:@"cell"];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    LYFNearbyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 100;
}

/** 左上角返回点击方法 */
- (void)backButtonAction:(UIBarButtonItem *) backButton {
    [self.navigationController popToRootViewControllerAnimated:YES];
}

/** 数据解析 */
- (void)dataHandle {
    [WxlAPPTools GETWithURL:@"http://ic.snssdk.com/neihan/user/nearby/v1/?iid=3884185944&os_version=9.3&os_api=18&app_name=joke_essay&channel=App%20Store&device_platform=iphone&idfa=F2C266F2-2A1C-4D42-85CC-07B17EE56F90&vid=68B1D0A2-5547-4C3F-B88A-D9B55797F72D&openudid=15d474a633f829aabda5b6e1420e0253418080e8&device_type=iPhone%206%20Plus&version_code=5.0.1&ac=WIFI&screen_width=1242&device_id=12502863248&aid=7&gender=-1&latitude=38.88036100773768&longitude=121.5415375850468" par:nil success:^(id responseObject) {
        
    } filed:^(NSError *error) {
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
